//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "CandidateDBForPGSearch.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* filenameBindingProfile = NULL;
  String* filenameCATHProfile    = NULL;
  String* filenameOut            = NULL;
  
  if (argc < 4) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./GetContinuousSeqForBindingRegion <In File - Ligand FASTA Profile>";
    cout <<                                   " <In File - CATH FASTA Profile>";
    cout <<                                   " <Out File>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenameBindingProfile  = new String(argv[1]);
    filenameCATHProfile     = new String(argv[2]);
    filenameOut             = new String(argv[3]);
    
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    cout << " In File - Ligand FASTA Profile : " << argv[1] << endl;
    cout << "   In File - CATH FASTA Profile : " << argv[2] << endl;
    cout << "                       Out File : " << argv[3] << endl;
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  CandidateDBForPGSearch* candidateDBForPGSearch = new CandidateDBForPGSearch ();
  
  cout << "Preparing Files..." << endl;
  candidateDBForPGSearch->FilenameBindingProfile(filenameBindingProfile);
  candidateDBForPGSearch->FilenameCATHProfile(filenameCATHProfile);
  candidateDBForPGSearch->FilenameOut(filenameOut);
  
  cout << "Loading the data..." << endl;
  if (!candidateDBForPGSearch->LoadData())
    cout << "Error Loading data!" << endl;

  candidateDBForPGSearch->HideDuplicated();

  cout << "Write the continuous residues information for the binding site of sequences..." << endl;
  candidateDBForPGSearch->WriteSequencesBindingRegion();
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (candidateDBForPGSearch) delete candidateDBForPGSearch;
  
  if (filenameBindingProfile) delete filenameBindingProfile;
  if (filenameCATHProfile)    delete filenameCATHProfile;
  if (filenameOut)            delete filenameOut;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

